//
//  CMLOE.h
//  CocoaMesh
//
//  Created by George  Armah on 4/28/09.
//  Copyright 2009 Lafayette College. All rights reserved.
//

/*!
 @header Cloud Mesh Operating Environment
 @discussion CMLOE class represents the Cloud Live Operating Environment. It is the main entry point to Mesh.
 */
#import <Foundation/Foundation.h>


@class CMResource;
@class CMMeshObject;

/*!
 @class CMLOE
 @abstract CMLOE represents the Cloud Mesh Operating Environment.
 @discussion This class performs CRUD operations on various Mesh Objects as well as Resource Scripts.
 It also handles authentication and connecting to the Mesh Operating Environment.
 */
@interface CMLOE : NSObject 
{
	NSString * authToken;
	NSMutableDictionary * topLevelMeshDictionary;

}

@property (nonatomic, retain) NSString * authToken;
@property (nonatomic, retain) NSMutableDictionary * topLevelMeshDictionary;

/*!
 @method connectWithUserID:password:applicationID:connectionError:
 @abstract Connects to Cloud MOE with user's credentials.
 @discussion This method obtains the authentication token for a correctly credentialed user. This is
 stored as the property - authToken. It uses delegated Authentication to connect. The application ID is
 supplied by the developer who calls this method, her username and password will most likely be different
 from the username and password of the application user.
 @param userID A string specifying user's Live ID
 @param uPassword A string specifying user's Live ID password
 @param applicationID A string specifying application ID obtained by user of this method to be used for 
 delegated Authentication
 @param connectionError Double pointer to NSError object for reporting back connection errors
 */
-(BOOL)connectWithUserID:(NSString*)userID 
				password:(NSString*)uPassword 
		   applicationID:(NSString*)appID
		 connectionError:(NSError**)err;

/*!
 @method loadMeshObjectsSynchronously:
 @abstract Synchronously obtains an array of 
 */
-(NSArray*)loadMeshObjects:(NSError**)err;
-(BOOL)updateResource:(CMResource*)resource error:(NSError**)err;
-(BOOL)deleteResource:(CMResource*)resource error:(NSError**)err;

-(CMMeshObject*)loadMeshObjectWithKey:(NSString*)key forValue:(NSString*)value error:(NSError**)err;
-(CMMeshObject*)createMeshObject:(NSError**)err;
@end
